<?php
    include($_SERVER['DOCUMENT_ROOT'].'/CTAN/models/tietmuc.php');
    $tietmuc = new tietmuc();

    if (isset($_REQUEST['action'])){
        $action = ($_REQUEST['action']);
        if ($action=="insert"){
            //INSERT COMMAND
            $tietmuc->setMaTietMuc($_REQUEST['ma_tiet_muc']);
            $insertType = $_REQUEST['type'];
            if ($insertType == "themnghesi"){
                //them nghe si vao tiet muc
                $manghesi = $_REQUEST['ma_nghe_si'];
                $result = $tietmuc->themNgheSiVaoTietMuc($manghesi);
                echo $result;
            }
            elseif ($insertType == "themnhom"){
                $manhom = $_REQUEST['ma_nhom'];
                $result = $tietmuc->themNhomNhacVaoTietMuc($manhom);
                echo $result;
            }
        }
        elseif ($action=="delete") {
            $tietmuc->setMaTietMuc($_REQUEST['ma_tiet_muc']);
            $ma_nghe_si = $_REQUEST['ma_nghe_si'];
            $result = $tietmuc->xoaNgheSiKhoiTietMuc($ma_nghe_si);
            echo $result;
        }
    }
?>
